/**
 * Created by x on 17-8-29.
 */
angular.module('passwordEnter', []).component(
    'passwordEnter',
    {
        templateUrl: 'component/welfare/password.template.html',
        controller: [
            '$scope', '$rootScope','Api','Alert', '$state','welfareModel',

            function ($scope,$rootScope, Api,Alert, $state,welfareModel) {
                $scope.welfareModels = new welfareModel()
                $scope.releaseWelfare = releaseWelfare
                $scope.welfared = []
                function releaseWelfare(welfare) {
                    welfare.payChannel = 'BALANCE';
                    welfare.password = welfare.password
                    welfare.note = $rootScope.note;
                    for(var i=0;i < $rootScope.selectLists.length;i++){
                        var targetId = ($rootScope.selectLists[i]).personId
                        $scope.welfared.push({"targetId":targetId,'totalFee':$rootScope.totalFee})
                        welfare.welfare = $scope.welfared;
                    }
                    Api.creatWelfare(welfare,null,function (result) {
                        $scope.welfareModels = new welfareModel()
                        $state.go('company.companyWelfare')
                    })
                }
            }
        ]
    }
);
